Skip to content

Conversation

@bend-n
Copy link
Contributor

@bend-n bend-n commented Sep 26, 2025

adds the const_array feature
reimplements try_map in more or less the same way

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Sep 26, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@bend-n bend-n marked this pull request as ready for review September 26, 2025 18:44
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 26, 2025
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Sep 26, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 26, 2025

r? @ibraheemdev

rustbot has assigned @ibraheemdev.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

else {
// SAFETY: this slice will contain only initialized objects.
unsafe {
x.array_mut.get_unchecked_mut(..x.initialized).assume_init_drop();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What part of this isn't const evaluable? The get_unchecked_mut?

Copy link
Contributor Author

@bend-n bend-n Oct 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assume_init_drop, and changing it to be const had some rammifications for some reason, causing some tests to fail. #147071 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like just trivial stderr file changes. Feel free to just bless them.

But is that code path testable in const? Since it's only happening in a panic path, I think it's unreachable anyway in const contexts. They never unwind and never will unwind. So maybe just document that and move the entire drop method body into the non-const code path... Or can we keep it non-const and avoid any drop happening for it by "disarming it" in the success path?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its used in try_from_fn, so it can get dropped in const context?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right. Hmm. Wondering how to write an observable test for this. I think if you use a type with a reference to a Cell and in its const drop impl increment that cell, you should see in a const context that the cell isn't incremented if try_map errors/returns None.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah oops, wanted to write this test but forgot about it when I was on a computer.

Need to reinvestigate this to get it all back into cache.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It oughtnt really be needed now, as the behaviour is identical to the non const version?

@oli-obk oli-obk assigned oli-obk and unassigned ibraheemdev Oct 11, 2025
@rustbot
Copy link
Collaborator

rustbot commented Oct 11, 2025

The Miri subtree was changed

cc @rust-lang/miri

@bend-n bend-n force-pushed the const_array-ops branch 3 times, most recently from e95a529 to 0021344 Compare October 11, 2025 11:43
@bend-n bend-n force-pushed the const_array-ops branch 2 times, most recently from 43edafa to 7bec7a4 Compare October 11, 2025 12:03
@rustbot

This comment has been minimized.

where
F: [const] FnMut(T) -> U,
{
extern "rust-call" fn call_mut(&mut self, (i,): (usize,)) -> Self::Output {
Copy link
Contributor Author

@bend-n bend-n Oct 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be possible to ignore this i and just use moved, but, uh, i think that would be somewhat confusing.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Nov 26, 2025

Some changes occurred in src/tools/cargo

cc @ehuss

@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

Copy link
Contributor

@oli-obk oli-obk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a rebase fragemtn and a nit

View changes since this review

@rustbot
Copy link
Collaborator

rustbot commented Nov 27, 2025

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@oli-obk
Copy link
Contributor

oli-obk commented Nov 27, 2025

@bors r+

@bors
Copy link
Collaborator

bors commented Nov 27, 2025

📌 Commit e3a2c23 has been approved by oli-obk

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 27, 2025
bors added a commit that referenced this pull request Nov 27, 2025
Rollup of 8 pull requests

Successful merges:

 - #147071 (constify from_fn, try_from_fn, try_map, map)
 - #148930 (tweak editor configs)
 - #149320 (-Znext-solver: normalize expected function input types when fudging)
 - #149363 (Port the `#![windows_subsystem]` attribute to the new attribute system)
 - #149378 (make run-make tests use 2024 edition by default)
 - #149381 (Add `impl TrustedLen` on `BTree{Map,Set}` iterators)
 - #149388 (remove session+blob decoder construction)
 - #149390 (`rust-analyzer` subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit b1b3e5e into rust-lang:main Nov 27, 2025
11 checks passed
@rustbot rustbot added this to the 1.93.0 milestone Nov 27, 2025
rust-timer added a commit that referenced this pull request Nov 27, 2025
Rollup merge of #147071 - bend-n:const_array-ops, r=oli-obk

constify from_fn, try_from_fn, try_map, map

adds the `const_array` feature
reimplements `try_map` in more or less the same way
@bend-n bend-n deleted the const_array-ops branch November 28, 2025 04:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants